package com.lwq.imserver.controller;

import com.lwq.imserver.model.ChatRoom;
import com.lwq.imserver.service.ChatRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Description:
 * Author: LiuWenQing
 * Datetime: 2022/1/29 22:15
 */
@RestController
public class ChatRoomController {

    @Autowired
    private ChatRoomService chatRoomService;

    @GetMapping("chatRoom")
    @CrossOrigin("*")
    public List<ChatRoom> queryByUserId(@RequestParam String userId){
        return chatRoomService.queryByUserId(userId);
    }


    @PostMapping("chatRoom")
    @CrossOrigin("*")
    public void add(@RequestBody ChatRoom model){
        chatRoomService.add(model);
    }


    @DeleteMapping("chatRoom/{id}")
    @CrossOrigin("*")
    public void delete(@PathVariable String id,@RequestParam String userId){
        chatRoomService.delete(id,userId);
    }
}
